/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cz.muni.fi.hauntedhouses.util;

import cz.muni.fi.hauntedhouses.entity.Users;
import cz.muni.fi.hauntedhouses.to.UsersTO;

/**
 *
 * @author honzaq
 */
public class UserUtil {
    public static UsersTO entityToTO(Users user) {
        if (user == null) {
            return null;
        }
        
        UsersTO userTo = new UsersTO();
        userTo.setId(user.getId());
        userTo.setUsername(user.getUsername());
        userTo.setPassword(user.getPassword());
        userTo.setEnabled(user.getEnabled());
        
        return userTo;
    }
    
    public static Users TOToEntity(UsersTO userTo) {
        if (userTo == null) {
            return null;
        }
        
        Users user = new Users();
        user.setId(userTo.getId());
        user.setUsername(userTo.getUsername());
        user.setPassword(userTo.getPassword());
        user.setEnabled(userTo.getEnabled());
        
        return user;
    }
}
